package com.xpc.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;

import static com.xpc.constant.PositionStateConstant.*;


/**
 * @author Qinkuer
 * @version 1.0.0
 * @ProjectName UniversityGradeAdministrationSystem
 * @ClassName Permissions.java
 * @Description TODO 菜单栏自动配置类 暂时版
 * @createTime 2022年05月23日 13:21:00
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Permissions {
    //菜单id
    private Integer permissionID;
    //菜单名
    private String name;
    //router路径
    private String path;

    private String redirect;
    
    //View文件路径
    private  String component;
    //显示信息
    private String comment;
    //图标
    private String icon;
    //菜单权限
    private Integer category;

    public Permissions(Integer permissionID, String name, String path, String component, String comment, String icon, Integer category) {
        this.permissionID = permissionID;
        this.name = name;
        this.path = path;
        this.component = component;
        this.comment = comment;
        this.icon = icon;
        this.category = category;
    }

    ArrayList<Permissions> children;

    public Permissions(int positionState){
        switch (positionState){
            case COUNSELOR_POSITION_STATE_INT:
                counselor();
                break;
            case COMMITTEE_GRADE_POSITION_STATE_INT:
            case COMMITTEE_GRADE_CLASS_POSITION_STATE_INT:
                committeeGrade();
                break;
            case COMMITTEE_CLASS_POSITION_STATE_INT:
                committeeClass();
                break;
            default:
                student();
        }
    }
    private void student(){
        setPermissionID(10);
        setCategory(1);
        setName("layout");
        setPath("/");
        setComponent("@/views/Layout");
        ArrayList<Permissions> childrenList = new ArrayList<>();

        //主页
        Permissions home = new Permissions(100,"home","home","@/views/Home","首页","icon-icon-test",2);
        //个人信息
        Permissions userInfo = new Permissions(200,"userInfo","user_info","@/views/UserInfo","个人中心","icon-icon-test",2);

        //事务管理
        Permissions a = new Permissions(300,"transctions","transactions","@/views/test","事务管理中心","icon-icon-test11",1);
        a.setRedirect("to_do_list");
        ArrayList<Permissions> a_childrenList = new ArrayList<>();
        //事务管理子目录
        Permissions a1 = new Permissions(301, "toDoList", "to_do_list","@/views/Transactions/ToDoList", "待办事项", "icon-icon-test5", 2);
        Permissions a2 = new Permissions(302, "allTransactions", "all_transactions","@/views/Transactions/AllTransactions", "所有事务", "icon-icon-test20", 2);
        a_childrenList.add(a1);
        a_childrenList.add(a2);
        a.setChildren(a_childrenList);

        childrenList.add(home);
        childrenList.add(userInfo);
        childrenList.add(a);
        this.setChildren(childrenList);
    }

    private void counselor(){
        setPermissionID(10);
        setCategory(1);
        setName("layout");
        setPath("/");
        setComponent("@/views/Layout");
        ArrayList<Permissions> childrenList = new ArrayList<>();

        //主页
        Permissions home = new Permissions(100,"home","home","@/views/Home","首页","icon-icon-test",2);
        //个人信息
        Permissions userInfo = new Permissions(200,"userInfo","user_info","@/views/UserInfo","个人中心","icon-icon-test",2);

        //事务管理
        Permissions a = new Permissions(300,"transctions","transactions","@/views/test","事务管理中心","icon-icon-test11",1);
        a.setRedirect("to_do_list");
        ArrayList<Permissions> a_childrenList = new ArrayList<>();
        //事务管理子目录
        Permissions a1 = new Permissions(301, "toDoList", "to_do_list","@/views/Transactions/ToDoList", "待办事项", "icon-icon-test5", 2);
        Permissions a3 = new Permissions(303, "transactionManagement", "transaction_management","@/views/Transactions/TransactionManagement", "事务管理", "icon-icon-test8", 2);
        Permissions a2 = new Permissions(302, "allTransactions", "all_transactions","@/views/Transactions/AllTransactions", "所有事务", "icon-icon-test20", 2);
        Permissions a4 = new Permissions(304, "createTransaction", "create_transaction","@/views/Transactions/CreateTransaction", "新建事务", "icon-icon-test19", 2);
        a_childrenList.add(a1);
        a_childrenList.add(a2);
        a_childrenList.add(a3);
        a_childrenList.add(a4);
        a.setChildren(a_childrenList);

        // 任职管理
        Permissions b = new Permissions(400, "postManagement", "post_management","@/views/test", "任职管理", "icon-icon-test11", 1);
        ArrayList<Permissions> b_childrenList = new ArrayList<>();
        Permissions b1 = new Permissions(401, "departmentManagement", "department_Management","@/views/PostManagement/DepartmentManagement", "年委任职管理", "icon-icon-test8", 2);
        Permissions b2 = new Permissions(402, "classManagement", "class_management","@/views/PostManagement/ClassManagement", "班委任职管理", "icon-icon-test8", 2);
        b_childrenList.add(b1);
        b_childrenList.add(b2);
        b.setChildren(b_childrenList);

        //学生信息
        Permissions c = new Permissions(500, "studentsInfo", "students_info","@/views/Students", "学生中心", "icon-icon-test11", 1);
        ArrayList<Permissions> c_childrenList = new ArrayList<>();
        Permissions c1 = new Permissions(501, "gradeInfo", "grade_info","@/views/Studengs/GradeInfo", "年级学生信息", "icon-icon-test8", 2);
        Permissions c2 = new Permissions(502, "classInfo", "class_info","@/views/Studengs/ClassInfo", "班级学生信息", "icon-icon-test8", 2);
        c_childrenList.add(c1);
        c_childrenList.add(c2);
        c.setChildren(c_childrenList);

        childrenList.add(home);
        childrenList.add(userInfo);
        childrenList.add(a);
        childrenList.add(b);
        childrenList.add(c);
        this.setChildren(childrenList);
    }

    private void committeeGrade(){
        setPermissionID(10);
        setCategory(1);
        setName("layout");
        setPath("/");
        setComponent("@/views/Layout");
        ArrayList<Permissions> childrenList = new ArrayList<>();

        //主页
        Permissions home = new Permissions(100,"home","home","@/views/Home","首页","icon-icon-test",2);
        //个人信息
        Permissions userInfo = new Permissions(200,"userInfo","user_info","@/views/UserInfo","个人中心","icon-icon-test",2);

        //事务管理
        Permissions a = new Permissions(300,"transctions","transactions","@/views/test","事务管理中心","icon-icon-test11",1);
        a.setRedirect("to_do_list");
        ArrayList<Permissions> a_childrenList = new ArrayList<>();
        //事务管理子目录
        Permissions a1 = new Permissions(301, "toDoList", "to_do_list","@/views/Transactions/ToDoList", "待办事项", "icon-icon-test5", 2);
        Permissions a3 = new Permissions(303, "transactionManagement", "transaction_management","@/views/Transactions/TransactionManagement", "事务管理", "icon-icon-test8", 2);
        Permissions a2 = new Permissions(302, "allTransactions", "all_transactions","@/views/Transactions/AllTransactions", "所有事务", "icon-icon-test20", 2);
        Permissions a4 = new Permissions(304, "createTransaction", "create_transaction","@/views/Transactions/CreateTransaction", "新建事务", "icon-icon-test19", 2);
        a_childrenList.add(a1);
        a_childrenList.add(a2);
        a_childrenList.add(a3);
        a_childrenList.add(a4);
        a.setChildren(a_childrenList);



        // 任职管理
        Permissions b = new Permissions(400, "postManagement", "post_management","@/views/test", "任职管理", "icon-icon-test11", 1);
        ArrayList<Permissions> b_childrenList = new ArrayList<>();
        Permissions b2 = new Permissions(402, "classManagement", "class_management","@/views/PostManagement/ClassManagement", "班委任职管理", "icon-icon-test8", 2);
        b_childrenList.add(b2);
        b.setChildren(b_childrenList);

        //学生信息
        Permissions c = new Permissions(500, "studentsInfo", "students_info","@/views/Students", "学生中心", "icon-icon-test11", 1);
        ArrayList<Permissions> c_childrenList = new ArrayList<>();
        Permissions c1 = new Permissions(501, "gradeInfo", "grade_info","@/views/Studengs/GradeInfo", "年级学生信息", "icon-icon-test8", 2);
        Permissions c2 = new Permissions(502, "classInfo", "class_info","@/views/Studengs/ClassInfo", "班级学生信息", "icon-icon-test8", 2);
        c_childrenList.add(c1);
        c_childrenList.add(c2);
        c.setChildren(c_childrenList);

        childrenList.add(home);
        childrenList.add(userInfo);
        childrenList.add(a);
        childrenList.add(b);
        childrenList.add(c);
        this.setChildren(childrenList);
    }

    private void committeeClass(){
        setPermissionID(10);
        setCategory(1);
        setName("layout");
        setPath("/");
        setComponent("@/views/Layout");
        ArrayList<Permissions> childrenList = new ArrayList<>();

        //主页
        Permissions home = new Permissions(100,"home","home","@/views/Home","首页","icon-icon-test",2);
        //个人信息
        Permissions userInfo = new Permissions(200,"userInfo","user_info","@/views/UserInfo","个人中心","icon-icon-test",2);

        //事务管理
        Permissions a = new Permissions(300,"transctions","transactions","@/views/test","事务管理中心","icon-icon-test11",1);
        a.setRedirect("to_do_list");
        ArrayList<Permissions> a_childrenList = new ArrayList<>();
        //事务管理子目录
        Permissions a1 = new Permissions(301, "toDoList", "to_do_list","@/views/Transactions/ToDoList", "待办事项", "icon-icon-test5", 2);
        Permissions a3 = new Permissions(303, "transactionManagement", "transaction_management","@/views/Transactions/TransactionManagement", "事务管理", "icon-icon-test8", 2);
        Permissions a2 = new Permissions(302, "allTransactions", "all_transactions","@/views/Transactions/AllTransactions", "所有事务", "icon-icon-test20", 2);
        Permissions a4 = new Permissions(304, "createTransaction", "create_transaction","@/views/Transactions/CreateTransaction", "新建事务", "icon-icon-test19", 2);
        a_childrenList.add(a1);
        a_childrenList.add(a2);
        a_childrenList.add(a3);
        a_childrenList.add(a4);
        a.setChildren(a_childrenList);

        //学生信息
        Permissions c = new Permissions(500, "studentsInfo", "students_info","@/views/Students", "学生中心", "icon-icon-test11", 1);
        ArrayList<Permissions> c_childrenList = new ArrayList<>();
        Permissions c2 = new Permissions(502, "classInfo", "class_info","@/views/Studengs/ClassInfo", "班级学生信息", "icon-icon-test8", 2);
        c_childrenList.add(c2);
        c.setChildren(c_childrenList);

        childrenList.add(home);
        childrenList.add(userInfo);
        childrenList.add(a);
        childrenList.add(c);
        this.setChildren(childrenList);
    }

}

